package com.example.syssoft.domain;


import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Where;
import org.springframework.security.core.GrantedAuthority;

import javax.persistence.*;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Entity
@Getter
@Setter
@Inheritance
@Where(clause = "is_deleted = 0")
@Table(name = "t_business")
@JsonIgnoreProperties(value = {"handler","hibernateLazyInitializer","fieldHandler"})
@DiscriminatorValue("0")
public class Business extends User{
    @Schema(description = "名称")
    @Column(length = 128)
    private String name;

    @Column(length = 512)
    @Schema(description = "描述")
    private String description;

    @OneToMany(mappedBy = "business",fetch = FetchType.EAGER,cascade = CascadeType.ALL)
    @JsonIgnoreProperties(value = {"business"})
    @Schema(description = "商店")
    private Set<Shop> shops;


    public Boolean addShop(Shop shop){
        return shops.add(shop);
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public boolean isAccountNonExpired() {
        return false;
    }

    @Override
    public boolean isAccountNonLocked() {
        return false;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return false;
    }

    @Override
    public boolean isEnabled() {
        return false;
    }
}
